/* 
  Copyright (c) SilverLining 2015
  Date:    2016-1-7
  File:    Message.h  
  Description: 

*/

#pragma once

namespace SL
{
	namespace M
	{
		ref class MessageType;

		/// <summary>
		/// Represent a managed game message.
		/// </summary>
		public ref class Message
		{
		public:
			~Message();
			!Message();

			/// <summary>
			/// Represent the sender of the message.
			/// </summary>
			/// <remarks>If the message did not originate from a managed process, this value will be null.</remarks>
			property Process^ Sender
			{
				/// <summary>
				/// Return the message sender.
				/// </summary>
				/// <returns>A process, or null if the message didn't originate from a managed process.</returns>
				Process^ get();
			}
			/// <summary>
			/// Represent the type of the message.
			/// </summary>
			property MessageType^ TypeId
			{
				/// <summary>
				/// Return the message type.
				/// </summary>
				/// <returns>A message type.</returns>
				MessageType^ get();
			}
			/// <summary>
			/// Represent the message data.
			/// </summary>
			/// <remarks>If the data does not have a corresponding managed type, this value will be null.</remarks>
			property System::Object^ Data
			{
				/// <summary>
				/// Return the message data.
				/// </summary>
				/// <returns>An object, or null if there is no data.</returns>
				System::Object^ get();
			}

			/// <summary>
			/// Represent the native representation of the message.
			/// </summary>
			/// <remarks>This can be used to get the native representation of a managed message.</remarks>
			property m::message* NativePtr
			{
				/// <summary>
				/// Returns the native message.
				/// </summary>
				/// <returns>A message.</returns>
				m::message* get();
			}

			System::String^ ToString() override;
			
			/// <summary>
			/// Return if the specified message type is equal to the message type.
			/// </summary>
			/// <param name="messageType">The message type.</param>
			/// <returns>True if the type matches.</returns>
			bool TypeEquals(MessageType^ messageType);

		internal:
			Message(m::message* message);

		private:
			Process^ _Sender;
			System::Object^ _data;
			m::message* _msg;
		};
	}
}